<%--
  Created by IntelliJ IDEA.
  User: dzw
  Date: 2017/11/30
  Time: 16:59
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@ page isELIgnored="false" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%
  String path = request.getContextPath();
  String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
  String _id=request.getParameter("_");
  String jsessionid = session.getId();
%>

<div class="panel">
  <div class="panel-heading header">
    <h3 class="panel-title" id="title">客户信息表</h3>
  </div>

  <!-- BASIC FORM ELEMENTS -->
  <!--===================================================-->
  <form id="form_customerInfo_input" class="form-horizontal">

    <input type="hidden" name="keyId" id="keyId" value="${customerInfo.id}"/>
    <input type="hidden" name="curDutyId" id="curDutyId" value=""/>

    <div class="form-group">
      <label class="col-md-2 control-label">
        <a href="javascript:void(0);" onclick="fn_customerInfo_dialog_select()" style="color: #4FA5D0">客户名称</a>
        <i class="fa fa-asterisk txt-color-red"></i>
      </label>
      <div class="col-md-6">
        <input type="text" id="name" name="name" class="form-control" placeholder="请输入客户名称" value="${customerInfo.name}">
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-2 control-label">客户类别<i class="fa fa-asterisk txt-color-red"></i></label>
      <div class="col-md-6">
        <input type="text" name="customerType" id="customerType" class="form-control" placeholder="请输入客户类别" value="${customerInfo.customerType}">
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-2 control-label">所在区域<i class="fa fa-asterisk txt-color-red"></i></label>
      <div class="col-md-6">
        <input type="text" name="area" id="area"  class="form-control" placeholder="请输入所在区域" value="${customerInfo.area}">
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-2 control-label">联系人<i class="fa fa-asterisk txt-color-red"></i></label>
      <div class="col-md-6">
        <input type="text" name="contacts" id="contacts"  class="form-control" placeholder="请输入联系人" value="${customerInfo.contacts}">
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-2 control-label">联系地址<i class="fa fa-asterisk txt-color-red"></i></label>
      <div class="col-md-6">
        <input type="text" name="address" id="address"  class="form-control" placeholder="请输入联系地址" value="${customerInfo.address}">
      </div>
    </div>

    <div class="form-group">
      <label class="col-md-2 control-label">联系方式<i class="fa fa-asterisk txt-color-red"></i></label>
      <div class="col-md-6">
        <input type="text" name="way" id="way"  class="form-control" placeholder="请输入联系方式" value="${customerInfo.way}">
      </div>
    </div>


  </form>
  <!--===================================================-->
  <!-- END BASIC FORM ELEMENTS -->

  <div class="panel-footer">
    <a class="btn btn-default" id="apply-re-common" href="javascript:void(0)">
      <i class="fa fa-lg fa-mail-reply"></i> 返回
    </a>
    <a class="btn btn-success" id="btn-save-common" href="javascript:void(0);"><i class="fa fa-lg fa-download"></i> 保存 </a>
    <c:if test="${customerInfo==null || customerInfo.processState=='Draft'}">
      <a class="btn btn-warning" id="btn-commit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 提交 </a>
    </c:if>
    <c:if test="${customerInfo!=null && customerInfo.processState=='Backed'}">
      <a class="btn btn-warning" id="btn-recommit-common" href="javascript:void(0);"><i class="fa fa-upload"></i> 再提交 </a>
    </c:if>
  </div>
</div>

<script>
  var index = "${index}";
  var todo = "${todo}";
  var remind = "${remind}";
  var record = "${record}";
  var draft =  "${draft}";

  $(function(){
    var pdata= {
      keyId:$("#keyId").val(),
      entityName:"com.fz.us.oa.core.entity.com.CustomerInfo"
    };
    multiDuty(pdata);
    fn_customerInfo_input_validate()
  });

  //选择规划许可
  function fn_customerInfo_dialog_select(){
    __open_dialog_select('选择客户信息', '<%=path%>/com/customerInfo/chooseCustomer', function (dialogRef) {
      var callback = function (data) {
        if (data) {
          dialogRef.close();
          $('#name').val(data.name);
          $('#customerType').val(data.customerType);
          $('#area').val(data.area);
        } else {
          dialogRef.enableButtons();
        }
      };
      fn_dialog_customerInfo_select(callback);
    });
  }

  // 表单数据校验
  function fn_customerInfo_input_validate() {
    __init_validate('form_customerInfo_input', {
      rules : {
        name : {
          required : true
        },
        customerType : {
          required : true
        },
        area : {
          required : true
        },
        contacts : {
          required : true
        },
        address:{
          required : true
        },
        way:{
          required : true
        }
      },
      messages : {
        name : {
          required : "请输入客户名称"
        },
        customerType : {
          required : "请输入客户类别"
        },
        area : {
          required : "请输入所在区域"
        },
        contacts : {
          required : "请输入联系人"
        },
        address : {
          required : "请输入联系地址"
        },
        way : {
          required : "请输入联系方式"
        }
      }
    });
  }

  //保存
  $("#btn-save-common").click(function(){
    __confirm_dialog("提示","确定保存吗？",function(){
      __form_save("form_customerInfo_input", "<%=path%>/com/customerInfo/save",function(){
        $("#apply-re-common").trigger("click");
      })
    })
  });

  //提交
  $("#btn-commit-common,#btn-recommit-common").click(function(){
    if (!$('#form_customerInfo_input').valid()) {
      return false;
    }
    __confirm_dialog("提示","确定提交吗？",function(){
      __form_save("form_customerInfo_input", "<%=path%>/com/customerInfo/commit",function(){
        $("#apply-re-common").trigger("click");
      })
    })
  });


  //返回视图
  $("#apply-re-common").click(function(){
    if(index==1){
      loadURL("menu/dashboard",$('#page-content'));
    }else if(todo==1){
      loadURL("menu/toDo",$('#page-content'));
    }else if(remind==1){
      loadURL("menu/remind",$('#page-content'));
    }else if(record==1){
      loadURL("menu/taskRecord?type=1",$('#page-content'));
    }else if(record==2){
      loadURL("menu/taskRecord?type=2",$('#page-content'));
    }else if(draft==1){
      loadURL("menu/draft",$('#page-content'));
    }else{
      returnToHashUrl()
    }
  });

</script>




